#include "buttonhoverwathcer.h"
#include <QPushButton>
#include <QEvent>

ButtonHoverWathcer::ButtonHoverWathcer(QObject *parent) : QObject(parent)
{

}

bool ButtonHoverWathcer::eventFilter(QObject * watched, QEvent * event)
{
    QPushButton * button = qobject_cast<QPushButton*>(watched);
    if (!button) {
     return false;
    }

    if (event->type() == QEvent::Enter) {
     // The push button is hovered by mouse
     button->setIcon(QIcon("://res/images/Downloading@2x.png"));
     return true;
    }

    if (event->type() == QEvent::Leave){
     // The push button is not hovered by mouse
     button->setIcon(QIcon("://res/images/mid_title_download.png"));
     return true;
    }

    return false;
}

